// https://www.luogu.com.cn/problem/P2677

#include <iostream>
#include <vector>
#include <numeric>
#include <bitset>
using namespace std;

int height[25];

int maxHeight(int b, int n, int sum) {
    bitset<32> dp;
    dp[0] = true;
    for (int i = 0; i < n; i++) {
        dp |= dp << height[i];
    }

    // for (int i = 0; i <= sum; i++) {
    //     printf("%d: %d\n", i, static_cast<int>(dp[i]));
    // }

    int ans = sum;
    for (int i = b; i <= sum; i++) {
        if (dp[i]) {
            ans = i - b;
            break;
        }
    }
    return ans;
}

int main() {
    int n, b;
    scanf("%d %d", &n, &b);
    for (int i = 0; i < n; i++) {
        scanf("%d", &height[i]);
    }
    int sum = accumulate(height, height+n, 0);
    printf("%d\n", maxHeight(b, n, sum));

    return 0;
}